package com.why.jvm.hotspot.src.share.vm.classfile;

import cn.hutool.core.io.FileUtil;
import com.why.jvm.hotspot.src.share.vm.oops.InstanceKlass;

import java.io.File;

/**
 * @author xiaoTian
 * @date 2022/7/17 06:20
 * @Description:
 */
public class BootstrapClassLoader {

    public static final String SUFFIX = ".class";

    /**
     * 读取字节码文件
     * @param name
     * @return
     */
    public static InstanceKlass loadClassFile(String name) throws Exception {
        // 读取
        byte[] content = FileUtil.readBytes(new File(name + SUFFIX));
        // 解析
        InstanceKlass instanceKlass = ClassFileParser.parseClassFile(content);
        return instanceKlass;
    }



}
